<template>
	<view>
		<view class="1">
			<view>
				<u-alert :title="title" type="warning" :closable="closable"></u-alert>
			</view>
			<view>
				<u-form :model="info" :rules="rules" ref='form1'>
					<u-form-item label="姓名" prop="ename" required borderBottom
						style="margin-left: 30rpx;margin-right: 20rpx;">
						<u-input v-model="info.ename" border="none"></u-input>
					</u-form-item>
					<u-form-item label="手机号码" labelWidth="150rpx" prop="phone" borderBottom ref="item1"
						style="margin-left: 30rpx;margin-right: 20rpx;">
						<u-input v-model="info.phone" border="none"></u-input>
					</u-form-item>
					<u-form-item label="部门" prop="department" borderBottom ref="item1"
						style="margin-left: 30rpx;margin-right: 20rpx;">
						<u-input v-model="info.department" border="none"></u-input>
					</u-form-item>
					<u-form-item label="上级负责人" labelWidth="180rpx" prop="superior" borderBottom ref="item1"
						style="margin-left: 30rpx;margin-right: 20rpx;">
						<u--input v-model="info.superior" border="none"></u--input>
					</u-form-item>
					<u-form-item label="报销金额(元)" labelWidth="190rpx" prop="reimbursement" borderBottom ref="item1"
						style="margin-left: 30rpx;margin-right: 20rpx;">
						<u--input v-model="info.reimbursement" border="none"></u--input>
					</u-form-item>
					<u-form-item label="员工类型" labelWidth="150rpx" prop="staff" borderBottom @click="showtype = true;"
						ref="item1" style="margin-left: 30rpx;margin-right: 20rpx;">
						<u--input v-model="info.staff" disabled disabledColor="#ffffff" placeholder="请选择员工类型"
							border="none"></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
					<u-form-item label="付款金额" labelWidth="150rpx" prop="payment" borderBottom ref="item1"
						style="margin-left: 30rpx;margin-right: 20rpx;">
						<u--input v-model="info.payment" border="none"></u--input>
					</u-form-item>
					<u-form-item>
						<view class="example-body" style="margin-left: 30rpx;margin-right: 20rpx;">
							<view class="" style="margin-bottom: 20rpx;margin-top: 20rpx;">
								付款时间
							</view>
							<uni-datetime-picker type="date" v-model="info.paymenttime" :clear-icon="false"
								@maskClick="maskClick" />
						</view>
					</u-form-item>
				</u-form>
				<u-action-sheet :show="showtype" :actions="staff" title="请选择员工类型" @close="showtype = false"
					@select="typeSelect">
				</u-action-sheet>
				<uni-card>
					<uni-title type="h3" title="审批人"></uni-title>
					<view>
						<u-avatar src="/static/img/fximage/x.jpg"></u-avatar>
						审批人：崔万里
					</view>
				</uni-card>
				<uni-card>
					<uni-title type="h3" title="抄送人"></uni-title>
					<view>
						<u-avatar src="/static/img/fximage/x.jpg"></u-avatar>
						抄送人：抄送专用
					</view>
				</uni-card>
				<view class="" style="margin: 20rpx;">
					<u-button type="primary" text="提交" @click="toupdate"></u-button>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import request from "../../../../utils/request.js"
	export default {
		data() {
			return {
				user:{},
				title: '报销提交申请后请于三个工作日内上交发票等票据',
				closable: true,
				showSex: false,
				showtype: false,
				showstate: false,
				info: {
					ename: '',
					phone: '',
					department: '',
					superior: '',
					staff: '',
					enclosure: 9,
					reimbursement: '',
					paymenttime: '',
					payment: '',
				},
				staff: [{
						name: '全职',
					},
					{
						name: '兼职',
					},
					{
						name: '实习'
					},
					{
						name: '临时工'
					},
					{
						name: '不详',
					},
				],
				rules: {
					name: [{
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					}]
				},

				radio: '',
				switchVal: false
			};
		},
		onLoad() {
			this.users();
		},
		methods: {
			users() {
				this.user = uni.getStorageSync('user')
			},
			sexSelect(e) {
				this.info.education = e.name
			},
			typeSelect(e) {
				this.info.staff = e.name
			},
			stateSelect(e) {
				this.info.usertype = e.name
			},
			toupdate() {
				this.$refs.form1.validate().then(res => {
					uni.request({
						url: 'http://localhost:9525/aduit/approve/addrz',
						method: 'POST',
						data: {
							ename: this.info.ename,
							phone: this.info.phone,
							department: this.info.department,
							staff: this.info.staff,
							// estimate:this.info.estimate=Date.parse(new Date(this.info.estimate))
							usertype: this.info.usertype,
							enclosure: 10,
							superior: this.info.superior,
							reimbursement: this.info.reimbursement,
							paymenttime: this.info.paymenttime = Date.parse(new Date(this.info
								.paymenttime)),
							payment: this.info.payment,
							status:this.user.eid,
							eids:this.user.eid,
							spid:1,

						},
						success: (res) => {
							console.log("通过")
							if (res.data.code == 20000) {
								uni.reLaunch({
									url: '/pages/index/C/review',
								})
							} else {
								uni.showToast({
									title: '我错了',
									icon: 'error'
								})
							}
						},
					});
				})
				console.log("点了")
			}
		},
	};
</script>

<style>

</style>
